import axios from 'axios'
axios.defaults.withCredentials = true

const isRelease = false

const protocol = location.protocol // 获取当前域
const isHttps = protocol.indexOf('https:') === 0 ? 1 : 0 // https必须在首位

let url = ''
if (isRelease) {
  url = isHttps ? 'https://huapu-power.com/api' : 'http://huapu-power.com/api' // 正式环境域名
} else {
  url = '/api'
}

const sever = axios.create({
  baseURL: url,
  timeout: 30000,
  withCredentials: true,
  headers: {
    'Content-Type': 'application/json'
  }
})
export default sever
